﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace TerenXNA
{
    class CameraStationary : Camera
    {
        public CameraStationary(World world)
        {
            coords.world = world;
            starex = screenWidth / 2;
            starey = screenHeight / 2;
            this.cameraType = ScreenMenu.CameraType.Static;
            loaded = true;
        }

        public CameraStationary(Coords coords)
        {
            this.coords = coords;
            starex = screenWidth / 2;
            starey = screenHeight / 2;
            this.cameraType = ScreenMenu.CameraType.Static;
            loaded = true;
        }

        public override Vector3 getEye()
        {
            return new Vector3(coords.obx, coords.oby, coords.obz);
        }

        public override Vector3 getTarget()
        {
            return new Vector3(coords.obx + (float)Math.Sin(coords.kato) * 35, coords.oby + /*(float)Math.Sin(*/coords.katov/*)*/ * 20, coords.obz + (float)Math.Cos(coords.kato) * 35);
        }

        public override Vector3 getUp()
        {
            return new Vector3(0, 1, 0);
        }

        public override Matrix view()
        {
            return Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, Game1.device.Viewport.AspectRatio, 1.0f, 9000.0f);
        }

        public override void mouseUpdate(MouseState mouseState)
        {
            base.mouseUpdate(mouseState);
        }

        // bardzo istotna funkcja, trzeba pamietac ze
        // swiat sklada sie z 'kafelkow', wiec punkt 0
        // bedzie w rogu aktualnego pola, wiec trzeba
        // trzymac wspolrzedne w granicach tego pola
        public void wspCheck()
        {
            if (coords.obx <= 0)
            {
                coords.obx += (Tile.width - 1);
                coords.aktwx--; 
            }
            if (coords.obx >= (Tile.width - 1))
            {
                coords.obx -= (Tile.width - 1);
                coords.aktwx++; 
            }
            if (coords.obz <= 0)
            {
                coords.obz += (Tile.height - 1);
                coords.aktwz--; 
            }
            if (coords.obz >= (Tile.height - 1))
            {
                coords.obz -= (Tile.height - 1);
                coords.aktwz++;
            }
        }
    }
}
